﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;

using ERMap;

namespace PhoneBook.ServerMoniter
{
    public class ServerMoniter
    {
        public static DataSet GetList()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" select * from b_servermoniter where isnull(isdel,0)=0");

            Hashtable param = new Hashtable();

            return ERMapHelper.getCustomData(sb.ToString(), param);
        }

        public static DataSet GetList(DateTime dtBegin, DateTime dtEnd)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" select * from b_servermoniter where isnull(isdel,0)=0 and LogTime between @begindate and @enddate order by IsWarn desc,LogTime desc");

            Hashtable param = new Hashtable();
            param.Add("begindate", dtBegin);
            param.Add("enddate", dtEnd);

            return ERMapHelper.getCustomData(sb.ToString(), param);
        }

        public static DataSet GetList(string strMonitorType, DateTime dtBegin, DateTime dtEnd)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" select * from b_servermoniter where isnull(isdel,0)=0 and LogTime between @begindate and @enddate and MoniterType=@monitertype order by IsWarn desc,LogTime desc");

            Hashtable param = new Hashtable();
            param.Add("begindate", dtBegin);
            param.Add("enddate", dtEnd);
            param.Add("monitertype", strMonitorType);

            return ERMapHelper.getCustomData(sb.ToString(), param);
        }

        public static void AddLog(Hashtable newLog)
        {
            newLog["id"] = "";
            newLog["logtime"] = DateTime.Now;

            ERMapHelper.setmodel("b_servermoniter", "id", newLog);
        }
    }
}
